Passed
Push — master ( 7eb853...bd974e )
by Kolja
01:08
created

jgfNode.js ➔ label   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
const check = require('check-types');
2
const { Guard } = require('./guard');
3
4
/**
5
 * A node object represents a node in a graph.
6
 */
7
class JGFNode {
8
9
    /**
10
     * Constructor
11
     * @param {string} id Primary key for the node, that is unique for the object type.
12
     * @param {string} label A text display for the node.
13
     * @param {object,null} metadata Metadata about the node.
14
     */
15
    constructor(id, label, metadata = null) {
16
        this.id = id;
17
        this.label = label;
18
        this.metadata = metadata;
19
    }
20
21
    set metadata(metadata) {
22
        if (check.assigned(metadata)) {
23
            Guard.assertValidMetadata(metadata);
24
        }
25
        this._metadata = metadata;
26
    }
27
28
    get metadata() {
29
        return this._metadata;
30
    }
31
}
32
33
module.exports = {
34
    JGFNode,
35
};